package com.hourupdate.network.client;

import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.net.Socket;
import java.net.UnknownHostException;

import org.apache.log4j.Logger;

public class MyClientSocket implements MyConnectionSocket{
	static final Logger logger = Logger.getLogger(MyClientSocket.class);
    //Attribute
    private Socket          connect;
    private PrintWriter     writer;
    
    public MyClientSocket(String ip,int port){
        try {
            connect = new Socket(ip,port);
            writer = new PrintWriter(new OutputStreamWriter(connect.getOutputStream()));
        } catch (UnknownHostException ex) {
            logger.error(ex.getMessage());
        } catch (IOException ex) {
            logger.error(ex.getMessage());
        }
    }
    public void send(String msg) {
        writer.println(msg);
        writer.flush();
    }
}
